# @Author  : haomh
# @Time    : 2025-10-22 17:02
# @Function:

# 计算1-100的和
# i = 1
# result = 0
# while i <= 100:
#     result += i
#     i += 1
# print(f'1-100的和是{result}')
#


# sum = 0
# for i in range(1,101):
#     sum += i
# print(sum)

# 应用2：计算1-100偶数累加和
# 方法一
j = 1
res1 = 0
while j <= 100:
    if j % 2 == 0:
        res1 += j
    j += 1
# print(res1)
print(f'1-100偶数的和是{res1}')
# sum = 0
# for i in range(1,101):
#     if i % 2 == 0:
#         sum += i
# print(sum)


# 方法2：计数器控制
# k = 0
# res2 = 0
# while k <= 100:
#     res2 += k
#     k += 2
# print(f'1-100偶数的和是{res2}')

k = 0
res1 = 0
while k <= 100:
    res1 += k
    k += 2
print(res1)